package com.lyf.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lyf.dao.DealtypeDao;
import com.lyf.pojo.Dealtype;
import com.lyf.util.DateUtil;

@Service
@Transactional
public class DealtypeService {

	@Autowired
	private DealtypeDao dao;
	
	public List<Dealtype> findAll(){
		return dao.findAllByOrder("desc", "createtime");
	}

	public Dealtype findById(String id) {
		return dao.get(id);
	}

	public void save(Dealtype dealtype) {
		dealtype.setCreatetime(DateUtil.getNow());
		//default color is:hui hong se
		dealtype.setColor("#b32e2e");
		dao.saveOrUpdate(dealtype);
	}
	
}
